import React, { Component } from 'react';
import {
  View,Text,StyleSheet,ScrollView,TextInput
} from 'react-native';
import pxToDp from '../common/comm';
import * as DATA from '../data/data';

export default class AccountAli extends Component {
  constructor(props){
    super(props);
    this.state={
      loginkey:'',
      list:[]
    };

    let _that = this;
    let data2 = 'loginkey='+this.state.loginkey;
    fetch(DATA.ACCOUNTALI_URL,{
      method: "POST",
      headers:{'Content-Type': 'application/x-www-form-urlencoded' },
      body: data2
    })
        .then((response) => {       // 数据解析方式
          if (response.ok) {
            return response.json();
          }
        })
        .then((responseData) => {       // 获取到的数据处理
          if(responseData.status == 1){
            _that.setState({
              list:responseData.zfb
            })
          }
        })
        .catch((error) => { // 错误处理
          alert('获取数据失败，请重试！');
        })
        .done();
  }
  static navigationOptions={
    headerTintColor:'#fff',
    headerTitle: '完善渠道',
    headerStyle: {
      backgroundColor: '#36ad50',
      height: pxToDp(110)
    },
    headerTitleStyle: {
      color: '#fff',
      fontSize: pxToDp(34)
    },
    gesturesEnabled :true
  }
  render() {
    return (
      <ScrollView
        contentContainerStyle={styles.contentContainer}
        keyboardDismissMode='on-drag'
      > 
        <View>
          <View style={styles.row}>
            <Text style={[styles.title,{marginLeft:pxToDp(25)}]}>支付宝账号：</Text>
            <TextInput autoFocus={true} underlineColorAndroid="transparent" style={styles.input}>{this.state.list.number}</TextInput>
          </View>  
          <View style={styles.row}>
            <Text style={[styles.title,{marginLeft:pxToDp(25)}]}>姓      名：</Text>
            <TextInput underlineColorAndroid="transparent" style={[styles.input, { marginLeft: pxToDp(10) }]} >{this.state.list.name}</TextInput>
          </View>  
        </View>  
        <Text style={{marginTop:pxToDp(50)}}>注：请如实填写真实信息，有助于日后提现</Text>
        <Text style={styles.submit}>提交</Text>
      </ScrollView>
    );
  }
}

var styles = StyleSheet.create({
    contentContainer: {
      paddingVertical: 20,
      alignItems:'center'
  },
  row: {
    flexDirection: 'row',
    alignItems: 'center',
    borderBottomWidth: pxToDp(1),
    borderBottomColor: '#ddd',
    height:pxToDp(100)
  },
  title: {
    fontWeight: 'bold',
    fontSize:pxToDp(26)
  },
  input: {
    width: pxToDp(450),
    fontSize:pxToDp(26)
  },
  submit: {
    width: pxToDp(400),
    height: pxToDp(70),
    backgroundColor: '#36ad50',
    color: '#fff',
    textAlign: 'center',
    textAlignVertical: 'center',
    borderRadius: pxToDp(50),
    fontSize: pxToDp(34),
    marginTop:pxToDp(100)
  }
  });
